package com.soulless.deep;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zenglei
 * @Description 功能描述
 * @date 2022/11/17 10:10
 */
public class Client {

    public static void main(String[] args) {
        /**
         * 创建原型对象
         */
        ConcretePrototype prototype = new ConcretePrototype();
        prototype.setAge(18);
        prototype.setName("soulless-深克隆");
        List<String> hobbies = new ArrayList<String>();
        hobbies.add("书法");
        hobbies.add("美术");
        prototype.setHobbies(hobbies);
        System.out.println(prototype);

        System.out.println("-----------克隆后-----------");
        /**
         * 拷贝原型对象
         */
        ConcretePrototype cloneType = prototype.deepClone();
        cloneType.getHobbies().add("技术控");
        System.out.println("原型对象 " + prototype);
        System.out.println("克隆对象 " + cloneType);

        System.out.println("原型对象爱好 " + prototype.getHobbies());
        System.out.println("克隆对象爱好 " + cloneType.getHobbies());
        System.out.println(prototype.getHobbies() == cloneType.getHobbies());
    }

}
